import myRequest from '../request.js'
import dicts from '@/config/dicts.js'

// 获取当前积分
export const getCurrentIntegral = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/member/memberPointsHistory/getMemberPointsHistoryVO', 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 积分明细
export const getIntegralInfo = (params) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/member/memberPointsHistory/getByPage', 'get', params).then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 看视频加积分
export const videoGetIntegral = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/point/video/member/watchable', 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 看完视频
export const videoSettlement = (id) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/point/video/member/${id}/completed`, 'put').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
//  当前已签到天数
export const getSignInNumber = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/members/sign/consecutive/days`, 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 签到
export const setSignInNumber = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/members/sign`, 'post').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 当天是否签到
export const whetherSign = () => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/members/sign/today/check`, 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}


